home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 10868 / 10868.xpi / modules / status.js < prev    next >
Encoding:
Text File  |  2010-02-02  |  2.8 KB  |  89 lines

  1. /***************************** BEGIN LICENSE BLOCK *****************************
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with the
  6. * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
  7. *
  8. * Software distributed under the License is distributed on an "AS IS" basis,
  9. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  10. * the specific language governing rights and limitations under the License.
  11. *
  12. * The Original Code is Weave Status.
  13. *
  14. * The Initial Developer of the Original Code is Mozilla Corporation.
  15. * Portions created by the Initial Developer are Copyright (C) 2009 the Initial
  16. * Developer. All Rights Reserved.
  17. *
  18. * Contributor(s):
  19. *  Edward Lee <edilee@mozilla.com> (original author)
  20. *
  21. * Alternatively, the contents of this file may be used under the terms of either
  22. * the GNU General Public License Version 2 or later (the "GPL"), or the GNU
  23. * Lesser General Public License Version 2.1 or later (the "LGPL"), in which case
  24. * the provisions of the GPL or the LGPL are applicable instead of those above.
  25. * If you wish to allow use of your version of this file only under the terms of
  26. * either the GPL or the LGPL, and not to allow others to use your version of
  27. * this file under the terms of the MPL, indicate your decision by deleting the
  28. * provisions above and replace them with the notice and other provisions
  29. * required by the GPL or the LGPL. If you do not delete the provisions above, a
  30. * recipient may use your version of this file under the terms of any one of the
  31. * MPL, the GPL or the LGPL.
  32. *
  33. ****************************** END LICENSE BLOCK ******************************/
  34.  
  35. const EXPORTED_SYMBOLS = ["Status"];
  36.  
  37. const Cc = Components.classes;
  38. const Ci = Components.interfaces;
  39. const Cr = Components.results;
  40. const Cu = Components.utils;
  41.  
  42. Cu.import("resource://weave/constants.js");
  43.  
  44. let Status = {
  45.   get login() this._login,
  46.   set login(code) {
  47.     this._login = code;
  48.  
  49.     if (code != LOGIN_SUCCEEDED)
  50.       this.service = LOGIN_FAILED;
  51.     else
  52.       this.service = STATUS_OK;
  53.   },
  54.  
  55.   get sync() this._sync,
  56.   set sync(code) {
  57.     this._sync = code;
  58.  
  59.     if (code != SYNC_SUCCEEDED)
  60.       this.service = SYNC_FAILED;
  61.     else {
  62.       this.service = STATUS_OK;
  63.       this.resetBackoff();
  64.     }
  65.   },
  66.  
  67.   get engines() this._engines,
  68.   set engines([name, code]) {
  69.     this._engines[name] = code;
  70.  
  71.     if (code != ENGINE_SUCCEEDED)
  72.       this.service = SYNC_FAILED_PARTIAL;
  73.   },
  74.  
  75.   resetBackoff: function resetBackoff() {
  76.     this.enforceBackoff = false;
  77.     this.backoffInterval = 0;
  78.     this.minimumNextSync = 0;
  79.   },
  80.   resetSync: function resetSync() {
  81.     this._engines = {};
  82.     this.partial = false;
  83.   },
  84. };
  85.  
  86. // Initialize various status values
  87. Status.resetBackoff();
  88. Status.resetSync();
  89.